package cn.itcast.ks.service.impl;

import cn.itcast.ks.common.ResponseResult;
import cn.itcast.ks.common.threadlocal.UserThreadLocalUtils;
import cn.itcast.ks.mapper.AssignmentMapper;
import cn.itcast.ks.pojo.Vos.AssignmentVo;
import cn.itcast.ks.pojo.dtos.ShowWorkDto;
import cn.itcast.ks.pojo.dtos.WorkDto;
import cn.itcast.ks.pojo.entity.Assignment;
import cn.itcast.ks.pojo.entity.User;
import cn.itcast.ks.pojo.entity.UserStudentAssignment;
import cn.itcast.ks.service.IAssignmentService;
import cn.itcast.ks.service.IUserService;
import cn.itcast.ks.service.UserStudentAssignmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @author mwj
 * @date 2021/12/5
 * @TIME:17:39
 */
//
@Service
public class AssignmentServiceImpl extends ServiceImpl<AssignmentMapper, Assignment> implements IAssignmentService {
    @Autowired
    private AssignmentMapper assignmentMapper;
    //发布作业
    @Override
    public ResponseResult publishWork(WorkDto workDto) {
        //获得user-id
        User user = UserThreadLocalUtils.getUser();
        Integer userId = user.getId();

        Assignment assignment=new Assignment();
        assignment.setUserId(userId);
        BeanUtils.copyProperties(workDto,assignment);
        //添加到assignment
        assignmentMapper.addAss(assignment);

        return ResponseResult.okResult("作业发布成功");
    }
}
